package com.sne.airways.system.pojo;

import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.io.Serializable;

/**
 * Created with IntelliJ IDEA.
 * User: skyline{http://my.oschina.net/skyline520}
 * Date: 12-12-3
 * Time: 上午11:22
 * To change this template use File | Settings | File Templates.
 */
@Entity
@Table(name = "TD_ROLE_OPERATION")
@BatchSize(size=5)
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class TdRoleOperation implements Serializable {
    /**
     * 关联主键
     */
    @Id
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid",strategy = "uuid")
    @Column(name = "ROLEOPERATIONID",length = 45)
    private String roleOperationId;

    @ManyToOne(cascade ={CascadeType.PERSIST,CascadeType.MERGE},fetch=FetchType.LAZY)
    @JoinColumn(name = "ROLEID")
    private TdRole role;
    @ManyToOne(cascade ={CascadeType.PERSIST,CascadeType.MERGE},fetch=FetchType.LAZY)
    @JoinColumn(name = "OPERATIONID")
    private TdOperation operation;

    public String getRoleOperationId() {
        return roleOperationId;
    }

    public void setRoleOperationId(String roleOperationId) {
        this.roleOperationId = roleOperationId;
    }

    public TdRole getRole() {
        return role;
    }

    public void setRole(TdRole role) {
        this.role = role;
    }

    public TdOperation getOperation() {
        return operation;
    }

    public void setOperation(TdOperation operation) {
        this.operation = operation;
    }
    @Override
    public int hashCode() {
        return roleOperationId != null ? roleOperationId.hashCode() : 0;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (!(obj instanceof TdUser)) return false;

        TdRoleOperation tdRoleOperation = (TdRoleOperation) obj;

        if (roleOperationId != null ? !roleOperationId.equals(tdRoleOperation.roleOperationId) : tdRoleOperation.roleOperationId != null) return false;

        return true;
    }
}
